<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Laravel5.1配置--闫海的个人博客-芒果小叨</title>
<meta name="keywords" content="个人博客,闫海个人博客,laravel5.1,laravel5,laravel,la" />
<meta name="description" content="上一篇文章中安装好Laravel5.1后，你会发现访问时多了个public,懂apache配置的同学自己配一下就可以去掉这个public。这里还是顺带提一下。" />
<link href="/Public/Index/css/base.css" rel="stylesheet">
<link href="/Public/Index/css/new.css" rel="stylesheet">
<link rel="stylesheet" href="/Public/Index/css/animate.css">
<link rel="stylesheet" type="text/css" href="/Public/Admin/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css">
<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script><script type="text/javascript">uaredirect("http://yanhai0531.com/mobile.php");</script>
<!--[if lt IE 9]>
<script src="/Public/Index/js/modernizr.js"></script>
<![endif]-->

<script type="text/javascript" src="/Public/Admin/Js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/Public/Admin/ueditor/third-party/SyntaxHighlighter/shCore.js"></script>
<script type="text/javascript">
  SyntaxHighlighter.all();
</script>
<script type="text/javascript">
  var url = '/index/article';
  $(function(){
    var id = '47';
    $.post(url+'/addClick',{'id':id},function(data){
        $("#pclick").html('点击数：' + data);
    });
  })
</script>
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F5a97c6527b57694be765111b6a23bffc' type='text/javascript'%3E%3C/script%3E"));
</script>
</head>
<body>
<script src="/Public/Index/js/jquery.js"></script>
<div class='header animated bounceInDown'>
    <div class='wrap'>
      <div class='logo'><a data-scroll-reveal='enter from the top over 0.7s' href='/'>
         <img src='/Public/Index/images/logo.png' title='闫海的个人博客首页' alt="logo" /></a>
      </div>
      <div data-scroll-reveal='enter from the top over 0.7s' class='top-nav'>
          <ul id="topnav">
            <li><a href='/'  title='首页'>首页<span></span></a></li>
            <li><a href='/index/list/2.html' title='关于我'>关于我<span> </span></a></li><li><a href='/index/list/3.html' title='时光轴'>时光轴<span> </span></a></li><li><a href='/index/list/1.html' title='品味人生'>品味人生<span> </span></a></li><li><a href='/index/list/5.html' title='技术分享'>技术分享<span> </span></a></li>            <li><a href='/index/article/message.html'  title='给我留言'>给我留言<span></span></a></li>
          </ul>
      </div>
      <div class='clear'></div>
    </div>
</div>
<article class="blogs">
  <h1 class="t_nav">
  	<span>您当前的位置：<a href="/index.html">首页</a>&nbsp;&gt;&nbsp;
	<a href="/index/list/5.html">技术分享</a>
	&nbsp;&gt;&nbsp;<a href="/index/list/17.html">Laravel教程</a>
	
  	</span>  <a href="/index.html" class="n1">网站首页</a>
  </h1>
  <div class="index_about">
    <h2 class="c_titile">Laravel5.1配置</h2>
    <p class="box_c"><span class="d_time">发布时间：2015-06-12 15:12</span><span>编辑：小叨</span><span id="pclick">点击数：323</span></p>
    <ul class="infos" style="word-break: break-all;">
      <p><span style="color: rgb(0, 0, 0);">上一篇文章中安装好Laravel5.1后，你会发现访问时多了个public,懂apache配置的同学自己配一下就可以去掉这个public。这里还是顺带提一下。</span></p><p><span style="color: rgb(0, 0, 0);">比如你用的windows操作系统，安装的XAMPP，那么你可以照着来操作：</span></p><p><span style="color: rgb(0, 0, 0);">这里默认你已经安装了composer，并安装好了XAMPP。比如我想自己的项目叫做la，那需要在xampp/htdocs/中建立la文件夹，然后把你的<a style="color: rgb(0, 176, 240); text-decoration: underline;" target="_blank" href="https://github.com/laravel/laravel/archive/v5.1.0.zip"><span style="color: rgb(0, 176, 240);">laravel5.1</span></a>（下载其他版本可以<a style="color: rgb(0, 176, 240); text-decoration: underline;" target="_blank" href="https://github.com/laravel/laravel/"><span style="color: rgb(0, 176, 240);">点这里</span></a>，点branch：master然后在tags中选择版本，然后download）下载后解压到la文件夹中。</span></p><p><span style="color: rgb(0, 0, 0);">（为了演示一个多站点配置，在新建一个test文件夹做测试，里面放一个index.php）,写入：</span></p><pre class="brush:php;toolbar:false">&lt;?php
phpinfo();</pre><p><span style="color: rgb(0, 0, 0);">接下来配置XAMPP多站点。修改C盘WINDOWS\system32\drivers\etc目录下的 hosts 文件，添加：</span></p><pre class="brush:bash;toolbar:false">127.0.0.1&nbsp;mytest.com
127.0.0.1&nbsp;test.com</pre><p><span style="color: rgb(0, 0, 0);">打开xampp\apache\conf\httpd.conf文件，搜索 “Include conf/extra/httpd-vhosts.conf”，确保前面没有 # 注释符，也就是确保引入了 vhosts 虚拟主机配置文件。</span></p><p><span style="color: rgb(0, 0, 0);">在虚拟主机设置文件xampp\apache\conf\extra\httpd-vhosts.conf里设置：取消 NameVirtualHost *:80 前面的 ##，这样就启用了 vhosts.conf ，默认的httpd.conf默认配置失效。虚拟主机配置将只设置在 httpd-vhosts.conf 里。</span></p><p><span style="color: rgb(0, 0, 0);">添加：</span></p><pre class="brush:bash;toolbar:false">&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;E:/xampp/htdocs/la/public&quot;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;mytest.com
&lt;/VirtualHost&gt;
&lt;Directory&nbsp;&quot;E:/php/wordpress&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;Indexes&nbsp;FollowSymLinks&nbsp;Includes&nbsp;ExecCGI&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride&nbsp;All&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Order&nbsp;allow,deny&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;from&nbsp;all
&lt;/Directory&gt;
&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;E:/xampp/htdocs/test&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;test.com
&lt;/VirtualHost&gt;
&lt;Directory&nbsp;&quot;E:/php/wordpress&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;Indexes&nbsp;FollowSymLinks&nbsp;Includes&nbsp;ExecCGI&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride&nbsp;All&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Order&nbsp;allow,deny&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;from&nbsp;all
&lt;/Directory&gt;
&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;E:/xampp/htdocs/&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;localhost
&lt;/VirtualHost&gt;</pre><p><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">重启apache。参照</span><a style="text-decoration: underline; color: rgb(0, 176, 240);" target="_blank" href="http://www.yanhai0531.com/index/article/46.html"><span style="color: rgb(0, 176, 240);">之前的文章</span></a>，配置composer.json添加日本镜像，然后cmd中：</p><pre class="brush:bash;toolbar:false">E:
cd&nbsp;xampp/htdocs/la
composer&nbsp;install</pre><p>安装laravel<span style="color: rgb(0, 0, 0);">框架依赖包</span>，<span style="color: rgb(0, 0, 0);">把根目录的</span><code><span style="color: rgb(0, 0, 0);">.enb.example</span></code><span style="color: rgb(0, 0, 0);">重命名.env，<span style="color: rgb(0, 0, 0);">随机生成一个项目的加密key</span>，然后访问mytest.com,你会同样看到laravel的欢迎信息。。然后访问test.com你会发现phpinfo输出的信息。这样多站点就配置完成了。</span></p><p><span style="color: rgb(0, 0, 0);">顺带提一下，laravel中的默认时间是UTC，我们需要改成中国时间，在config/app.php中修改为&#39;timezone&#39; =&gt; &#39;PRC&#39;就可以了。</span></p>    </ul>
    <div class="keybq">
    <p><span>关键字词</span>：laravel5.1,laravel5,laravel,la</p>
    
    </div>
    <div class="ad"> </div>
    <div class="nextinfo">
      <p>上一篇：<a href="/index/article/46.html">laravel5.1安装</a></p>
      <p>下一篇：<a href="/index/article/48.html">【Laravel5教程】mac+apache+mysql配置多站点(一)</a></p>
    </div>
    <div class="otherlink">
      <h2>相关文章</h2>
      <ul>
        <li><a href="/index/article/48.html" title="【Laravel5教程】mac+apache+mysql配置多站点(一)">【Laravel5教程】mac+apache+mysql配置多站点(一)</a></li><li><a href="/index/article/47.html" title="Laravel5.1配置">Laravel5.1配置</a></li><li><a href="/index/article/46.html" title="laravel5.1安装">laravel5.1安装</a></li><li><a href="/index/article/45.html" title="初探Laravel5">初探Laravel5</a></li>        
      </ul>
    </div>
  </div>
  <aside class="right">
    <div class="news" style="margin-top:10px;">
    <h3>
	<p>最新<span>文章</span></p>
</h3>
	<ul class="rank">
		<li><a href="/index/article/49.html" title="新版网站完成50%了，继续加油吧" >新版网站完成50%了，继续加油吧</a></li><li><a href="/index/article/48.html" title="【Laravel5教程】mac+apache+mysql配置多站点(一)" >【Laravel5教程】mac+apache+mysql配置多站点(一)</a></li><li><a href="/index/article/47.html" title="Laravel5.1配置" >Laravel5.1配置</a></li><li><a href="/index/article/46.html" title="laravel5.1安装" >laravel5.1安装</a></li><li><a href="/index/article/45.html" title="初探Laravel5" >初探Laravel5</a></li><li><a href="/index/article/44.html" title="写了一个PHP框架" >写了一个PHP框架</a></li><li><a href="/index/article/42.html" title="当遇到问题时应该怎样去处理？" >当遇到问题时应该怎样去处理？</a></li><li><a href="/index/article/41.html" title="我的近况和计划" >我的近况和计划</a></li>	</ul>
<h3 class="ph">
    <p>点击<span>排行</span></p>
</h3>
	<ul class="paih">
    	<li><a href="/index/article/31.html" title="关于网站限制ie10以下浏览器访问的探讨" >关于网站限制ie10以下浏览器访问的探讨</a></li><li><a href="/index/article/46.html" title="laravel5.1安装" >laravel5.1安装</a></li><li><a href="/index/article/47.html" title="Laravel5.1配置" >Laravel5.1配置</a></li><li><a href="/index/article/45.html" title="初探Laravel5" >初探Laravel5</a></li><li><a href="/index/article/41.html" title="我的近况和计划" >我的近况和计划</a></li>	</ul>
<h3 class="links">
	<p>友情<span>链接</span></p>
</h3>
	<ul class="website">
		<li><a href="http://www.vso8.com" target="_blank">v8视频</a></li><li><a href="http://www.huanyun.net.cn" target="_blank">焕云企业管理有限公司</a></li><li><a href="http://www.sinkuo.com" target="_blank">济宁网站建设</a></li>	</ul>    </div>  
    <!-- Baidu Button BEGIN -->
    <div id="bdshare" class="bdshare_t bds_tools_32 get-codes-bdshare"><a class="bds_tsina"></a><a class="bds_qzone"></a><a class="bds_tqq"></a><a class="bds_renren"></a><span class="bds_more"></span><a class="shareCount"></a></div>
    <script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=6574585" ></script> 
    <script type="text/javascript" id="bdshell_js"></script> 
    <script type="text/javascript">

document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script> 
    <!-- Baidu Button END -->   
    <a onclick="javascript:window.open('/Public/Index/images/weixin.jpg','a', 'height=600,width=600,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');" class="weixin"> </a></aside> 
</article>
<footer>
  <p><a href="http://www.miitbeian.gov.cn/" target="_blank">Copyright © 2015 yanhai All Rights Reversed | 鲁ICP备15004472号-1</a> </p>
</footer>
<script src="/Public/Index/js/silder.js"></script>

<script type="text/javascript">
     if(typeof(Worker) === "undefined"){
     	$.get('/Public/Html5/html5.html', function(data){
			$('body').html(data);
		})
     }
</script>

</body>
</html>